<!DOCTYPE html>
<html>
<head>
<base href="${basePath}">
<meta charset="UTF-8">
<title>创建区域</title>
$!{include("import_js_css.html")}
<link rel="stylesheet" type="text/css" href="/yueyoga_all2014/app/admin/resources/css/basic.css" />
</head>
<body>
	$!{include("header.html")}
	<div class="menu_all">
		<div class="div_search_result clear">
			<div class="panel-heading panel-result-title">
				<h3 class="panel-title">创建区域</h3>
			</div>
			<div class="panel-form-add">
				<form class="form-horizontal" action="yueyogaAdmin/addArea.jhtml" method="POST">
					<div class="panel-form-layout">
						<label for="inputName" class="col-sm-1 control-label">名　称</label>
						<div class="col-sm-3">
							<input type="text" class="form-control" name="name" id="inputName" required value="${name}">
						</div>
						<label for="inputProvince" class="col-sm-1 control-label">所在省</label>
						<div class="col-sm-3">
							<!--#var(Area area,List<Area> provinces, List<Area> citys, List<Area> areas, List<Area> domains)-->
							<select id="inputProvince" data-live-search="true" style="width:100%;"
								class="selectpicker show-tick" data-width="100%" required name="provinceId">
								<option value="">请选择</option>
								<!--#foreach(area in provinces)-->
									<option value="${area.areaId}">${area.name}</option>
								<!-- #end -->
							</select>
						</div>
						<br /> <br />

						<label for="inputCity" class="col-sm-1 control-label">所在市</label>
						<div class="col-sm-3">
							<!-- #var(Area provinceArea) -->
							<select id="inputCity" data-live-search="true" style="width:100%;"
								class="selectpicker show-tick" data-width="100%" required name="cityId">
								<option value="">请选择</option>
							</select>
						</div>
						<label for="inputArea" class="col-sm-1 control-label">所在区</label>
						<div class="col-sm-3">
							<!-- #var(Area cityArea) -->
							<select id="inputArea" data-live-search="true" style="width:100%;"
								class="selectpicker show-tick" data-width="100%" required name="areaId">
								<option value="">请选择</option>
							</select>
						</div>
						<br /> <br />
						<div class="panel-btn-search">
							<button type="submit" class="btn btn-default btn-ade-default panel-mr">保存</button>
						</div>
					</div>
				</form>
				<script type="text/javascript">
					$(function() {
						$("#selTaskType").change(function() {
							var taskType = $(this).val();
							if (taskType == 2) {
								$("#ta_mbr_div").hide();
								$("#ta_gps_div").show();
							} else {
								$("#ta_gps_div").hide();
								$("#ta_mbr_div").show();
							}
						});
						var msg = '${msg}';
						if (msg) {
							alert(msg);
						}
					});
					//省
					$("#inputProvince").change(function() {
						var parentId = $(this).val();
						$.post(
							"yueyogaAdmin/subArea.jhtml",
							{"level": "1", "parentId": parentId},
							function(response) {
								var sub = document.getElementById("inputCity");
								var res = eval("(" + response + ")");
								var id = null;
								var name = null;
								var option = null;
								sub.options.length=0;
								option = new Option("请选择", "");
								sub.options.add(option);
								for(var i=0;i<res.items.length;i++) {
									id = res.items[i].areaId;
									name = res.items[i].name;
									option = new Option(name, id);
									sub.options.add(option);
								}
								var sub1 = document.getElementById("inputArea");
								sub1.options.length=0;
								option = new Option("请选择", "");
								sub1.options.add(option);
							}
						);
					});
				
					//市
					$("#inputCity").change(function() {
						var parentId = $(this).val();
						$.post(
							"yueyogaAdmin/subArea.jhtml",
							{"level": "2", "parentId": parentId},
							function(response) {
								var sub = document.getElementById("inputArea");
								var res = eval("(" + response + ")");
								var id = null;
								var name = null;
								var option = null;
								sub.options.length=0;
								option = new Option("请选择", "");
								sub.options.add(option);
								for(var i=0;i<res.items.length;i++) {
									id = res.items[i].areaId;
									name = res.items[i].name;
									option = new Option(name, id);
									sub.options.add(option);
								}
							}
						);
					});
					$('.selectpicker').select2();
				</script>
			</div>
		</div>
	</div>
</body>
</html>